package routes

import (
	"app_log_server/http/controllers"

	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
)

func RegisterRoutes(r *gin.Engine) {
	setCors(r)
	api_group := r.Group("/api")
	api_group.GET("/project", controllers.GetProjectList)
}

func setCors(ctx *gin.Engine) {
	ctx.Use(cors.New(cors.Config{
		AllowOrigins:     []string{"*"},
		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE"},
		AllowHeaders:     []string{"Origin", "Content-Type", "Authorization", "Content-Length"},
		ExposeHeaders:    []string{"Content-Length"},
		AllowCredentials: true,
	}))
}
